package com.pic.mgt.dao.syushin;

import java.util.Map;
import java.util.Vector;

import org.springframework.dao.DataAccessException;

import com.pic.mgt.dao.TargetMessageDao;
import com.pic.mgt.utils.SqlScriptUtils;

public final class SyushinTargetMessageDao extends TargetMessageDao implements
		ISyushinTargetMessageDao {
	// 資料表名稱
	private final String tableName = "syushin_target_message";
	
	private final String insertBasicSqlScript;
	
	public SyushinTargetMessageDao() {
		super();
		
		// 建立 Insert Basic 的 Sql Script
		insertBasicSqlScript = createInsertBasicSQLScript();
	}
	
	public String createInsertBasicSQLScript() {
		Vector<String> insertBasicFieldsVector = new Vector<String>();
		
		// 要新增的欄位
		insertBasicFieldsVector.add(_confirmationFile);
		insertBasicFieldsVector.add(_transactionFile);
		insertBasicFieldsVector.add(_transactionTime);
		insertBasicFieldsVector.add(_unitName);
		insertBasicFieldsVector.add(_terminalId);
		// (送多方新增)
		insertBasicFieldsVector.add(_apName);

		return SqlScriptUtils.createNamedParamInsertScript(this.tableName,
														   insertBasicFieldsVector);
	}

	@Override
	public int insertBasic(Map<String, Object> insertValuesMap)
			throws DataAccessException {
		if (null != insertValuesMap && !insertValuesMap.isEmpty()) {
			return
				super.namedParameterJdbcTemplate.update(this.insertBasicSqlScript,
														insertValuesMap);
		}
		else {
			return 0;
		}
	}
	
	@Override
	public String getTableName() {
		return this.tableName;
	}
}
